﻿using AutoMapper;
using SIG.DAL.Dapper.Repositories;
using SIG.Model.Teams;
using SIG.Service;
using SIG.ViewModel.Front.Teams;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SIG.WebMVC.Controllers
{
    public class TeamController : BaseController
    {
      
        private readonly TeamRepository _teamService;
        private readonly PageMetaRepository _pageMetaService;
    
        public TeamController()
        {
            _teamService = new TeamRepository();
            _pageMetaService = new PageMetaRepository();

        }

        // GET: Team
        public ActionResult Index()
        {
            var list = _teamService.GetActiveTeams().OrderByDescending(m => m.Importance).AsEnumerable();
            
            var vm = new PageTeamsVM()
            {
                Teams = list,
            };
            var url = Request.RawUrl;
            vm.PageMeta = _pageMetaService.GetPageMeta(DAL.Dapper.Model.ModelType.MENU, url);
            return View(vm);
        }
    }
}